package com.ruoyi.project.flink.latest;

import lombok.extern.slf4j.Slf4j;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;
import org.apache.kafka.common.config.Config;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

@Slf4j
class MySlink extends RichSinkFunction<String> {
    private  AnnotationConfigApplicationContext context;
    public MySlink() {
        log.info("MySlink new");
    }

    @Override
    public void open(Configuration parameters) throws Exception {
        this.context = new AnnotationConfigApplicationContext(Config.class);
        log.info("MySlink open");
    }

    @Override
    public void invoke(String value, Context context) {
        log.info("调用了invoke方法" + value);
    }

    @Override
    public void close() throws Exception {
        context.close();
        log.info("MySlink close");
    }
}
